/**
 * @param {number[]} nums
 * @param {number} val
 * @return {number}
 */
var removeElement = function(nums, val) {
  while(nums.length && nums.indexOf(val) !== -1) {
    const index = nums.indexOf(val);
    nums.splice(index, 1);
  }
  return nums.length;
};
let nums = [3,2,2,3], val = 3;
console.log(removeElement(nums, val));
nums = [0,1,2,2,3,0,4,2], val = 2;
console.log(removeElement(nums, val));

